package cn.gxust.ui;

import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Region;
import javafx.scene.paint.Paint;
import javafx.scene.shape.SVGPath;

/**
 * <p>description:  </p>
 * <p>create:  2020/11/18 9:50</p>
 * @author zhaoyijie(AquariusGenius)
 */
public class PlaySvg {

    private final Region preRegion;

    private final Region nextRegion;

    private final SVGPath preSvgPath;

    private final SVGPath pauseSvgPath; /* ||*/

    private final SVGPath playSvgPath; /* >*/

    private final SVGPath nextSvgPath;

    private final Region closeRegion;

    private final Region playOrPauseRegion;

    public PlaySvg() {
        this.pauseSvgPath = new SVGPath();
        this.pauseSvgPath.setContent("M511.580807 0.053181c281.898232 0 511.474444 229.629393 511.474444 511.527626s-229.576212 511.528668-511.474444 511.528668S0 793.533263 0 511.635031 229.682574 0 511.580807 0v0.053181z m0 949.645296c241.321971 0 438.063446-196.741475 438.063446-438.11767 0-241.321971-196.741475-438.116627-438.116628-438.116628C270.205654 73.464179 73.410998 270.205654 73.410998 511.580807c0 241.376196 196.741475 438.11767 438.116627 438.11767h0.053182zM410.851324 320.130346c18.428872 0 33.368635 14.939764 33.368635 33.368636v317.002036c0 18.428872-14.939764 33.368635-33.368635 33.368636-18.428872 0-33.368635-14.939764-33.368636-33.368636V353.498982c0-18.428872 14.939764-33.368635 33.368636-33.368636z m200.211812 0c18.428872 0 33.368635 14.939764 33.368636 33.368636v317.002036c0 18.428872-14.939764 33.368635-33.368636 33.368636-18.428872 0-33.368635-14.939764-33.368635-33.368636V353.498982c0-18.428872 14.939764-33.368635 33.368635-33.368636z");
        this.playSvgPath = new SVGPath();
        this.playSvgPath.setContent("M512 1024C229.248 1024 0 794.752 0 512S229.248 0 512 0s512 229.248 512 512-229.248 512-512 512z m0-938.666667C276.352 85.333333 85.333333 276.352 85.333333 512s191.018667 426.666667 426.666667 426.666667 426.666667-191.018667 426.666667-426.666667S747.648 85.333333 512 85.333333z m253.269333 441.856c-0.725333 2.048-0.896 4.181333-1.962666 6.144-0.469333 0.938667-1.365333 1.450667-1.92 2.346667-1.450667 2.346667-3.370667 4.309333-5.290667 6.357333-1.749333 1.834667-3.370667 3.669333-5.418667 5.077334-0.853333 0.64-1.408 1.621333-2.346666 2.218666l-333.482667 205.184a42.410667 42.410667 0 0 1-24.661333 12.245334c-1.92 0.426667-3.797333 0.981333-5.76 1.152L384 768c-0.341333 0-0.597333-0.170667-0.938667-0.213333a37.930667 37.930667 0 0 1-29.098666-12.202667c-0.170667-0.128-0.256-0.341333-0.426667-0.512-2.346667-2.517333-4.906667-4.778667-6.656-8.021333-0.597333-1.109333-0.597333-2.304-1.066667-3.456-1.066667-2.176-1.536-4.565333-2.176-6.912-0.725333-2.730667-1.493333-5.333333-1.664-8.106667C341.888 727.424 341.333333 726.485333 341.333333 725.333333V299.648c-0.170667-7.594667 0.853333-15.274667 4.650667-22.314667a39.253333 39.253333 0 0 1 34.517333-20.650666C381.738667 256.597333 382.762667 256 384 256c0.554667 0 1.024 0.298667 1.621333 0.341333l0.341334 0.042667a41.941333 41.941333 0 0 1 29.781333 14.464l332.885333 204.202667c1.237333 0.768 1.962667 2.005333 3.114667 2.901333 0.682667 0.512 1.237333 1.194667 1.877333 1.792a40.661333 40.661333 0 0 1 8.917334 10.752l0.469333 0.554667c0.213333 0.469333 0.213333 0.981333 0.426667 1.450666 2.090667 4.224 3.541333 8.576 4.224 13.312 0.170667 1.28 0.170667 2.474667 0.256 3.712a45.653333 45.653333 0 0 1-0.768 11.776c-0.426667 2.048-1.194667 3.925333-1.877334 5.888zM426.666667 376.064v272.64l221.866666-136.533333-221.866666-136.106667z");
        this.preSvgPath = new SVGPath();
        this.preSvgPath.setContent("M512 961.610044c248.312412 0 449.610044-201.297632 449.610044-449.610044s-201.297632-449.610044-449.610044-449.610044-449.610044 201.297632-449.610044 449.610044S263.687588 961.610044 512 961.610044zM237.492996 237.492996c35.672454-35.672454 77.196173-63.67215799 123.416867-83.222423 47.821145-20.22667 98.655927-30.482245 151.09116-30.482245 52.435233 0 103.270015 10.255575 151.09116 30.482245 46.22069399 19.549242 87.744413 47.549969 123.416867 83.222423 35.672454 35.672454 63.67215799 77.196173 83.222423 123.416867 20.22667 47.821145 30.482245 98.655927 30.482245 151.090137 0 52.435233-10.255575 103.270015-30.482245 151.09116-19.549242 46.22069399-47.549969 87.744413-83.222423 123.416867-35.672454 35.672454-77.196173 63.67215799-123.416867 83.222423-47.821145 20.22667-98.654904 30.482245-151.09116 30.482245-52.435233 0-103.268992-10.255575-151.09116-30.482245-46.22069399-19.549242-87.744413-47.549969-123.416867-83.222423-35.672454-35.672454-63.67215799-77.196173-83.222423-123.416867-20.22667-47.821145-30.482245-98.655927-30.482245-151.09116 0-52.435233 10.255575-103.268992 30.482245-151.090137C173.820837 314.689169 201.820542 273.16545 237.492996 237.492996zM448.346261 516.01954701L715.830315 718.332299c3.094478 1.786693 6.961552-0.446162 6.96155199-4.019547l0-404.625504c0-3.57236201-3.868097-5.806239-6.96155199-4.019547l-267.484054 202.31275199C445.252807 509.767146 445.252807 514.232854 448.346261 516.01954701zM305.848826 717.950605l92.229564 0c2.56338199 0 4.640694-2.365884 4.640694-5.28333l0-401.334551c0-2.917446-2.078335-5.28333-4.640694-5.28333l-92.229564 0c-2.56338199 0-4.640694 2.365884-4.640694 5.28333L301.208133 712.667276C301.208133 715.584722 303.28544401 717.950605 305.848826 717.950605z");
        this.nextSvgPath = new SVGPath();
        this.nextSvgPath.setContent("M512 62.389956c-248.312412 0-449.610044 201.297632-449.610044 449.610044s201.297632 449.610044 449.610044 449.610044 449.610044-201.297632 449.610044-449.610044S760.312412 62.389956 512 62.389956zM786.507004 786.507004c-35.672454 35.672454-77.196173 63.672158-123.416867 83.222423-47.821145 20.22667-98.655927 30.482245-151.09116 30.482245-52.435233 0-103.270015-10.255575-151.09116-30.482245-46.220694-19.549242-87.744413-47.549969-123.416867-83.222423-35.672454-35.672454-63.672158-77.196173-83.222423-123.416867-20.22667-47.821145-30.482245-98.655927-30.482245-151.090137 0-52.435233 10.255575-103.270015 30.482245-151.09116 19.549242-46.220694 47.549969-87.744413 83.222423-123.416867 35.672454-35.672454 77.196173-63.672158 123.416867-83.222423 47.821145-20.22667 98.654904-30.482245 151.09116-30.482245 52.435233 0 103.268992 10.255575 151.09116 30.482245 46.220694 19.549242 87.744413 47.549969 123.416867 83.222423 35.672454 35.672454 63.672158 77.196173 83.222423 123.416867 20.22667 47.821145 30.482245 98.655927 30.482245 151.09116 0 52.435233-10.255575 103.268992-30.482245 151.090137C850.179163 709.310831 822.179458 750.83455 786.507004 786.507004zM575.653739 507.980453 308.169685 305.667701c-3.094478-1.786693-6.961552 0.446162-6.961552 4.019547l0 404.625504c0 3.572362 3.868097 5.806239 6.961552 4.019547l267.484054-202.312752C578.747193 514.232854 578.747193 509.767146 575.653739 507.980453zM718.151174 306.049395l-92.229564 0c-2.563382 0-4.640694 2.365884-4.640694 5.28333l0 401.334551c0 2.917446 2.078335 5.28333 4.640694 5.28333l92.229564 0c2.563382 0 4.640694-2.365884 4.640694-5.28333L722.791867 311.332724C722.791867 308.415278 720.714556 306.049395 718.151174 306.049395z");
        this.playOrPauseRegion = new Region();
        this.preRegion = new Region();
        this.nextRegion = new Region();
        this.closeRegion = new Region();
    }

    public void changeSvgPath(PlayStatus playStatus) {
        if (PlayStatus.PLAY == playStatus) {
            playOrPauseRegion.setShape(playSvgPath);
        } else if (PlayStatus.PAUSE == playStatus) {
            playOrPauseRegion.setShape(pauseSvgPath);
        }
    }

    public Region getPreRegion(double wh, Paint paint) {
        preRegion.setShape(preSvgPath);
        preRegion.setMinSize(wh, wh);
        preRegion.setPrefSize(wh, wh);
        preRegion.setMaxSize(wh, wh);
        preRegion.setBackground(new Background(new BackgroundFill(paint, null, null)));
        return preRegion;
    }

    public Region getNextRegion(double wh, Paint paint) {
        nextRegion.setShape(nextSvgPath);
        nextRegion.setMinSize(wh, wh);
        nextRegion.setPrefSize(wh, wh);
        nextRegion.setMaxSize(wh, wh);
        nextRegion.setBackground(new Background(new BackgroundFill(paint, null, null)));
        return nextRegion;
    }

    public Region getPlayOrPauseRegion(double wh, Paint paint) {
        playOrPauseRegion.setShape(playSvgPath);
        playOrPauseRegion.setMinSize(wh, wh);
        playOrPauseRegion.setPrefSize(wh, wh);
        playOrPauseRegion.setMaxSize(wh, wh);
        playOrPauseRegion.setBackground(new Background(new BackgroundFill(paint, null, null)));
        return playOrPauseRegion;
    }

    public Region getCloseRegion(double wh, Paint paint) {
        SVGPath svgPath = new SVGPath();
        svgPath.setContent("M621.469971 490.921719l399.945118-399.945117a52.380261 52.380261 0 0 0 0-73.659742l-2.182511-2.182511a52.380261 52.380261 0 0 0-73.659742 0L545.627718 415.625094 145.682601 15.134349a52.380261 52.380261 0 0 0-73.659742 0L69.840348 17.31686a51.357209 51.357209 0 0 0 0 73.659742l399.945117 399.945117-399.945117 399.945118a52.380261 52.380261 0 0 0 0 73.659742l2.182511 2.182511a52.380261 52.380261 0 0 0 73.659742 0L545.627718 566.763972l399.945118 399.945118a52.380261 52.380261 0 0 0 73.659742 0l2.182511-2.182511a52.380261 52.380261 0 0 0 0-73.659742L621.469971 490.921719z");
        closeRegion.setShape(svgPath);
        closeRegion.setMinSize(wh, wh);
        closeRegion.setPrefSize(wh, wh);
        closeRegion.setMaxSize(wh, wh);
        closeRegion.setBackground(new Background(new BackgroundFill(paint, null, null)));
        return closeRegion;
    }
    public enum PlayStatus {
        PLAY,/* >*/
        PAUSE; /* ||*/
    }
}


